package org.jeecg.modules.rental.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.rental.entity.RentalUrgentAssist;
import org.jeecg.modules.rental.mapper.RentalUrgentAssistMapper;
import org.jeecg.modules.rental.service.IRentalUrgentAssistService;
import org.springframework.stereotype.Service;

/**
 * @Description: 紧急求助
 * @Author: sean
 * @Date:   2024-07-25
 * @Version: V1.0
 */
@Service
public class RentalUrgentAssistServiceImpl extends ServiceImpl<RentalUrgentAssistMapper, RentalUrgentAssist> implements IRentalUrgentAssistService {

//    @Autowired
//    private RentalEBikeMapper rentalCarMapper;

//    @Autowired
//    private IControlAPI iControlAPI;

    @Override
    public IPage<RentalUrgentAssist> selectJoinPage(Page page, RentalUrgentAssist entity) {
        return baseMapper.selectJoinPage(page, entity);
    }

    @Override
    public void report(RentalUrgentAssist rentalUrgentAssist) {
        if (rentalUrgentAssist.getCarId()!=null){
            //TODO 查询车辆位置，保存需要维护车辆的经纬度
//                RentalCar car=rentalCarMapper.selectById(rentalUrgentAssist.getCarId());
//                if (car!=null){
//                    Location location=iControlAPI.queryLByDeviceId(car.getCarCode());
//                    if (location!=null){
//                        double[] gcj02 = iControlAPI.gpsToGcj02(location.getLatitude(), location.getLongitude());
//                        rentalUrgentAssist.setLatitude(String.valueOf(gcj02[0]));
//                        rentalUrgentAssist.setLongitude(String.valueOf(gcj02[1]));
//                    }
//                }
        }
        baseMapper.insert(rentalUrgentAssist);
    }
}
